package com.hhkj.admin.bank.common.mybatis.handler;

import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONWriter;
import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;
import com.hhkj.admin.bank.model.extend.QuestionOrderRule;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;

/**
 * QuestionOrderRuleHandler
 *
 * @author ZhengJun
 * @since 2023/5/22 19:12
 */
@Slf4j
@MappedJdbcTypes(JdbcType.VARCHAR)
public class QuestionOrderRuleHandler extends AbstractJsonTypeHandler<QuestionOrderRule> {
    @Override
    protected QuestionOrderRule parse(String json) {
        return JSONObject.parseObject(json, QuestionOrderRule.class);
    }

    @Override
    protected String toJson(QuestionOrderRule obj) {
        return JSONObject.toJSONString(obj,
                JSONWriter.Feature.WriteNullListAsEmpty,
                JSONWriter.Feature.WriteMapNullValue,
                JSONWriter.Feature.WriteNullStringAsEmpty
        );
    }
}
